import { _decorator, CCInteger, Component, Node, Vec3 } from 'cc';
import { globalObserver } from '../observer/GlobalObserver';
const { ccclass, property } = _decorator;

@ccclass('Player')
export class Player extends Component {

    @property(CCInteger)
    speed: number = 2;

    protected onLoad(): void {
        globalObserver.on('control-move', this.move, this);
    }

    move(moveDir: Vec3){
        console.log(this.node.position);
        this.node.setPosition(this.node.getPosition().add(new Vec3 (moveDir.x*this.speed, moveDir.y*this.speed, 0)));
    }

    start() {

    }

    update(deltaTime: number) {
        
    }
}


